private _drive: persistence.Drive = null;
private _fileTree: teapo.files.FileTree = null;
private _docHost: docs.DocHost = null;
mainContentHost = ko.observable<HTMLElement>(null);
fileTreeHost = ko.observable<HTMLElement>(null);
var fileTree = new teapo.files.FileTree(this.fileTreeHost());
var uniqueKey = this._getUniqueKey();
var docHost = new docs.DocHost(this.mainContentHost(), mountedDrive);
this._fileTree = fileTree;
this._drive = mountedDrive;
this._fileTree.selectedFile.subscribe(newSelectedFile => this._docHost.show(newSelectedFile));
var typedFilename = prompt('Create file:', this._fileTree.selectedFile() || '/' ); var newFile = files.normalizePath(typedFilename);
if (this._drive.read(newFile) === null) { this._drive.write(newFile, '');
this._docHost.add(newFile);
this._fileTree.selectedFile(newFile);
var removeFile = this._fileTree.selectedFile();
if (!confirm('Remove file\n ' + removeFile + ' ?')) this._drive.write(removeFile, null);
this._docHost.remove(removeFile);
private _getUniqueKey() { var key = window.location.pathname;
var ignoreSuffix = '/index.html';
if (key.length > ignoreSuffix.length && key.slice(key.length - ignoreSuffix.length) === ignoreSuffix)
key = key.slice(0, key.length - ignoreSuffix.length);